//----------------------------------------------------------------------------
/** @file Engine.h */
//----------------------------------------------------------------------------

#ifndef AMIGOGTP_ENGINE_H
#define AMIGOGTP_ENGINE_H

#include <iosfwd>
#include "GtpEngine.h"
#include "Board.h"
#include "Interface.h"

//----------------------------------------------------------------------------

namespace amigogtp {

using namespace std;

//----------------------------------------------------------------------------

class Engine
    : public GtpEngine
{
public:
    Engine();

    /** @page enginecommands GTP Commands
        - @link CmdAllLegal() @c all_legal @endlink
        - @link CmdGroup() @c amigo-group @endlink
        - @link CmdIntboard() @c amigo-intboard @endlink
        - @link CmdKillable() @c amigo-killable @endlink
        - @link CmdPlayReason() @c amigo-play_reason @endlink
        - @link CmdSaveable() @c amigo-saveable @endlink
        - @link CmdSettings() @c amigo-settings @endlink
        - @link CmdBoardsize() @c boardsize @endlink
        - @link CmdClearBoard() @c clear_board @endlink
        - @link CmdGenmove() @c genmove @endlink
        - @link CmdAnalyzeCommands() @c gogui-analyze_commands @endlink
        - @link CmdIsLegal() @c is_legal @endlink
        - @link CmdKomi() @c komi @endlink
        - @link CmdName() @c name @endlink
        - @link CmdPlay() @c play @endlink
        - @link CmdRegGenmove() @c reg_genmove @endlink
        - @link CmdShowboard() @c showboard @endlink
        - @link CmdUndo() @c undo @endlink
        - @link CmdVersion() @c version @endlink */
    /** @name Command Callbacks */
    // @{
    virtual void CmdAllLegal(GtpCommand&);
    virtual void CmdAnalyzeCommands(GtpCommand&);
    virtual void CmdBoardsize(GtpCommand&);
    virtual void CmdClearBoard(GtpCommand&);
    virtual void CmdGenmove(GtpCommand&);
    virtual void CmdGroup(GtpCommand&);
    virtual void CmdIntboard(GtpCommand&);
    virtual void CmdIsLegal(GtpCommand&);
    virtual void CmdKillable(GtpCommand&);
    virtual void CmdKomi(GtpCommand&);
    virtual void CmdName(GtpCommand&);
    virtual void CmdPlay(GtpCommand&);
    virtual void CmdPlayReason(GtpCommand&);
    virtual void CmdRegGenmove(GtpCommand&);
    virtual void CmdSaveable(GtpCommand&);
    virtual void CmdSettings(GtpCommand&);
    virtual void CmdShowboard(GtpCommand&);
    virtual void CmdUndo(GtpCommand&);
    virtual void CmdVersion(GtpCommand&);
    // @} // @name

private:
    Board m_board;

    void Genmove(GtpCommand& cmd, bool play);

    void Play(const Point& p, Color c);

    Point PointArg(GtpCommand& cmd, size_t number) const;

    void Register(const string& name, GtpCallback<Engine>::Method method);

    Point StoneArg(GtpCommand& cmd, size_t number) const;

    Point StoneArg(GtpCommand& cmd) const;
};

//----------------------------------------------------------------------------

} // namespace amigogtp

//----------------------------------------------------------------------------

#endif // AMIGOGTP_ENGINE_H
